package com.bupt.godxian.charging.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bupt.godxian.charging.entity.ChargeArea;
import com.bupt.godxian.charging.entity.WaitArea;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WaitAreaMapper extends BaseMapper<WaitArea> {
    @Insert("INSERT INTO wait_area(request_id, type,WaitingAreaSize) VALUES (#{requestId}, #{type} ,6)")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(WaitArea waitArea);

    @Select("SELECT request_id FROM wait_area WHERE type = #{type} ORDER BY request_id ASC")
    List<Long> getCarInWaitAreaOrderByAsc(@Param("type") String type);

    @Delete("delete from wait_area where request_id=#{request_id}")
    void deleteById(String request_id);

    @Select("SELECT * FROM wait_area WHERE request_id = #{id}")
    List<WaitArea> selectByPrimaryKey(@Param("id") String id);

    // 可根据需要添加其他方法，如更新等候区、删除等候区等
    @Select("SELECT request_id FROM wait_area WHERE type = #{chargeMode}")
    List<String> selectWaitRequestIdsByChargeMode(@Param("chargeMode") String chargeMode);

    @Select("SELECT COUNT(*) FROM wait_area")
    Integer selectWaitAreaCarnum();
}
